home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Str / c / strncpycr < prev    next >
Text File  |  1995-07-08  |  1KB  |  33 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Misc.strncpycr.c
  12.     Author:  Copyright © 1994 Jason Howat
  13.     Version: 1.00 (18 Apr 1994)
  14.     Purpose: Copies a CR-terminated string - note that this will change the
  15.              terminator of the result to a NUL (0).
  16. */
  17.  
  18. #include "DeskLib:StringCR.h"
  19.  
  20.  
  21. extern char *strncpycr(char *s1, char *s2, int n)
  22. {
  23.   register char *end = s1 + n;
  24.  
  25.   while ((*s2 > 31) && (s1 != end))
  26.     *(s1++)  = *(s2++);
  27.  
  28.   if(s1 != end)                         /* copy terminator if space */
  29.     *s1 = 0;
  30.  
  31.   return(s1);
  32. }
  33.